package show.me.the.money.util.exp.standard;

import java.util.List;

import show.me.the.money.util.context.Context;
import show.me.the.money.util.exp.ExpRunner;
import show.me.the.money.util.exp.ExpSymbols;
import show.me.the.money.util.exp.Expression;
@SuppressWarnings("unchecked")
public class CONCAT extends Expression {
	public CONCAT() {
		symbol = ExpSymbols.CONCAT;
	}

	public String run(List lsExp, Context ctx) {
		StringBuffer buffer = new StringBuffer();
		try {
			int size = lsExp.size();
			for (int i = 1; i < size; i++) {
				List la = (List)lsExp.get(i);
				String s = (String)ExpRunner.run(la, ctx);
				buffer.append(s);
			}
		} catch (Exception e) {
			logger.fatal("run JSONException:", e);
		}
		return buffer.toString();
	}

	public String toString(List jsonExp, Context ctx) {
		return "'" + run(jsonExp, ctx) + "'";
	}

}
